using System.Linq;
using Service.Abstract;

namespace WebUI.Controllers
{
    public class TaskStatisticsController : BaseController
    {
        private readonly IUserService _userService;
        private readonly ITaskService _taskService;
        private readonly IProjectService _projectService;

        public TaskStatisticsController(IUserService userService, IProjectService projectService, ITaskService taskService)
            : base(userService)
        {
            _userService = userService;
            _taskService = taskService;
            _projectService = projectService;
        }
        #region Task count

        public int InboxCount()
        {
            return (CurrentUser != null ? _taskService.GetAllByUserId(CurrentUser.UserId).Where(x => x.ProjectId == 0 || x.ProjectId == null).Count() : 0);
        }

        public int UpcomingCount()
        {
            return (CurrentUser != null ? _taskService.GetAllByUserId(CurrentUser.UserId).Where(x => x.DateDue != null).Count() : 0);
        }

        public int FlaggedCount()
        {
            return (CurrentUser != null ? _taskService.GetAllByUserId(CurrentUser.UserId).Where(x => x.Flagged).Count() : 0);
        }

        public int AllTasksCount()
        {
            return (CurrentUser != null ? _taskService.GetAllByUserId(CurrentUser.UserId).Count() : 0);
        }

        #endregion
    }
}